package edu.jmu.action.sysmanage.role;

import javax.annotation.Resource;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.Validations;

import edu.jmu.action.privilege.Permission;
import edu.jmu.bean.privilege.Role;
import edu.jmu.service.sysmanage.RoleService;

@Controller 
@Namespace("/sysmanage")
@Scope(value="prototype")
public class DeleteRoleAction extends ActionSupport{
	private static final long serialVersionUID = 7611057405297768522L;
	@Resource
	private RoleService roleService;
	private Role role;
	
	@Validations(requiredFields={
			@RequiredFieldValidator(fieldName="role.roleId" , message ="ID错误！")
	})
	@Action(value="delRole" ,results={
			@Result(name=SUCCESS,type="redirectAction",params={
					"actionName", "roleList"
			}),
			@Result(name=INPUT,type="redirectAction",params={
					"actionName", "roleList"
			})
	})
	@Permission(module="role",privilege="delRole")
	public String deleteRole(){		
		roleService.delete(role.getRoleId());
		return SUCCESS;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}
	
	
}
